﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace _07_Mutex
{
    class Program
    {
        Mutex mutex = new Mutex(false);  //signalled

        void Thread1()
        {
            mutex.WaitOne();
            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine("id: {0}; i = {1}", Thread.CurrentThread.ManagedThreadId, i);
                Thread.Sleep(100);
            }
            mutex.ReleaseMutex();
        }

        static void Main(string[] args)
        {
            Program pr = new Program();
            new Thread(pr.Thread1).Start();
            new Thread(pr.Thread1).Start();
            new Thread(pr.Thread1).Start();
        }
    }
}
